/*!
\file ContainerElement.h
\brief Contains definition of ContainerElement.
\ingroup Algorithm
*/

#ifndef CONTAINERELEMENT_H 
#define CONTAINERELEMENT_H

#include"Node.h"
#include"Edge.h"
#include"Action.h"
#include<QObject>

//One element in our container class. Can hold one edge, one node, one int, one double and one QString. User should keep trash of what he's using it for himself.
/*!
\class ContainerElement
\brief One element for in the Container class. Can hold one Edge, one Node, one int, ont double and one QString. User should keep track of what he's using it for himself.
\ingroup Algorithm
*/

class ContainerElement: public QObject{
Q_OBJECT
public:
	ContainerElement();
	//!< Constructor. Creates an empty entry.
	~ContainerElement();
	//!< Destructor.
	
	ContainerElement *setNode( const Node &node );
	//!< Set Node. Delete used Node if any. Returns this pointer.
	ContainerElement *setEdge( const Edge &edge );
	//!< Set Edge. Delete used Edge if any. Returns this pointer.
	ContainerElement *setData( int data );
	//!< Set int data. Returns this pointer.
	ContainerElement *setData( double data );
	//!< Set double data. Return this pointer.
	ContainerElement *setData( QString data );
	//!< Set QString data. Return this pointer.
	
	const Node *node()const;
	//!< Return stored Node.
	const Edge *edge()const;
	//!< Return stored Edge.
	int dataInt()const;
	//!< Return stored int.
	double dataDouble()const;
	//!< Return stored double.
	QString dataString()const;
	//!< Return stored string.
	
	bool intUsed()const{ return m_intUsed; }
	//!< Return if int is set.
	bool doubleUsed()const{ return m_doubleUsed; }
	//!< Return if double is set.
	bool stringUsed()const{ return m_stringUsed; }
	//!< Return if string is set.
private:
	Node *m_node;
	Edge *m_edge;
	int m_dataInt;
	double m_dataDouble;
	QString m_dataString;
	bool m_intUsed, m_doubleUsed, m_stringUsed;
	void _reportChangedData();
	void _report( ContainerElementAction *action );
signals:
	void reportAction(ContainerElementAction*);
	//!< Used to report changes in this ContainerElement.
};

#endif

